@extends("layout.admin")

@section("title")
    标签
@endsection

@section("content")
    <link href="{{asset('css/table.css')}}" rel="stylesheet"/>

    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this"><a href="{{route('admin.tags.index')}}">标签</a></li>
            <li><a href="{{route('admin.tags.index.attach')}}">标签组</a></li>
        </ul>
    </div>
    {{--列表--}}
    <div class="layui-card-body ">
        <script type="text/html" id="toolbar">
            {{--添加--}}
            @if(_can("admin.tags.create"))
            <div class="layui-inline layui-show-xs-block">
                <a onclick="admin.openLayerForm('{{ route("admin.tags.create") }}', '添加标签', 'POST', '500px', 'auto',0,'#tag_create')"
                   class="layui-btn layui-btn-sm" data-type="auto" id="create"><i class="layui-icon"></i>添加</a>
            </div>
            @endif
        </script>
        <table class="layui-table" lay-data="{toolbar: '#toolbar',defaultToolbar:['filter'],limit:1000}">
            <thead>
            <tr>
                <th lay-data="{field:'id',width:80, fixed: 'left', unresize: true, sort: true}">编号</th>
                <th lay-data="{field:'name',width:150, }">名称</th>
                <th lay-data="{field:'groupname'}">组别</th>
                <th lay-data="{field:'created_at',hide:true}">创建时间</th>
                <th lay-data="{field:'updated_at',hide:true}">更新时间</th>
                <th lay-data="{field:'op',fixed: 'right', width:150, align:'center'}">操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach ($tags as $tag)
                <tr>
                    <td>{{ $tag['id'] }}</td>
                    <td>{{ $tag['name'] }}</td>
                    <td>{{ $tag['groupName'] }}</td>
                    <td>{{ $tag['created_at']}}</td>
                    <td>{{ $tag['updated_at']}}</td>
                    <td data-field="controller">
                        @if(_can("admin.tags.update"))
                            <a
                                onclick="admin.openLayerForm('{{route('admin.tags.update',['id'=>$tag['id']])}}', '编辑标签', 'POST', '500px', 'auto',0,'#tag_edit')"
                                class="layui-btn layui-btn-xs btn_edit">编辑</a>
                        @endif
                        @if(_can("admin.tags.destroy"))
                            <a onclick="admin.tableDataDelete('{{route('admin.tags.destroy',['id'=>$tag['id']])}}', this, '是否删除当前标签')"
                               class='layui-btn layui-btn-primary layui-btn-xs'>删除</a>
                        @endif

                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
@endsection
@section('script')
    <script>
        var idx = -1;
        layui.use(['form', 'table', 'layer'], function () {
            var table = layui.table;
        });
    </script>

    <script src="{{asset('js/layCommon.js')}}"></script>
@endsection
